/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
 * Description: rma buffer common interface
 */

#ifndef RMA_BUFFER_H
#define RMA_BUFFER_H

#include "hccl_common.h"
#include "hccl_inner_common.h"
#include "hccl_one_sided_services.h"

namespace hccl {
class RmaBuffer {
public:
    RmaBuffer(void *addr, u64 size, const HcclMemType memType, const RmaType rmaType)
        : addr(addr), size(size), memType(memType), rmaType(rmaType)
    {
    }

    virtual ~RmaBuffer() = default;

    RmaBuffer(const RmaBuffer &that) = delete;

    RmaBuffer &operator=(const RmaBuffer &that) = delete;

    inline void* GetAddr() const
    {
        return addr;
    }

    inline u64 GetSize() const
    {
        return size;
    }

    inline RmaType GetRmaType() const // used for grant check
    {
        return rmaType;
    }

    inline HcclMemType GetMemType() const
    {
        return memType;
    }

    inline void *GetDevAddr() const
    {
        return devAddr;
    }

protected:
    void*       addr{nullptr};
	u64         size{0};
    void*       devAddr{nullptr};
    HcclMemType memType{HcclMemType::HCCL_MEM_TYPE_NUM};
    RmaType     rmaType{RmaType::RMA_TYPE_RESERVED};
};
}
#endif //  RDMA_RMA_BUFFER_H